package interceptor

import (
	"google.golang.org/grpc"
	"log"
	"time"
)

// 流式拦截器

func StreamLoggerInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {

	log.Println(time.Now().Format("2006-01-02 15:04:05") + " " + info.FullMethod)

	err := handler(srv, ss)
	if err != nil {
		log.Println(time.Now().Format("2006-01-02 15:04:05") + " " + err.Error())
		return err
	}
	log.Println(time.Now().Format("2006-01-02 15:04:05") + " " + info.FullMethod)
	return nil

}
